package com.hd.tiyu.yuejian.Fragment;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.hd.tiyu.yuejian.Activity.ClubDetailActivity;
import com.hd.tiyu.yuejian.Activity.TrainActivity;
import com.hd.tiyu.yuejian.Adapter.TeacherAdpater;
import com.hd.tiyu.yuejian.JavaBean.ClubIntro;
import com.hd.tiyu.yuejian.Model.ListsModel;
import com.hd.tiyu.yuejian.R;
import com.squareup.picasso.Picasso;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import static android.R.id.list;
import static java.lang.System.load;

/**
 * Created by love on 2017/10/11.
 */

public class ClubIntroFragment extends Fragment {
    private View view;
    private TextView jianjie,telnum,place,time;
    private RecyclerView recyclerView;
    private String id;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view=inflater.inflate(R.layout.clubintrotab,container,false);
        Bundle bundle=getArguments();
        id=bundle.getString("id");
        initViews();
        initEvents();
        initData();
        return view;
    }

    private void initViews() {
        jianjie=view.findViewById(R.id.club_intro);
        telnum=view.findViewById(R.id.tex_tel);
        place=view.findViewById(R.id.tex_place);
        time=view.findViewById(R.id.tex_time);

        recyclerView=view.findViewById(R.id.teaclist);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    }
    private void initEvents() {
        ListsModel listsModel=new ListsModel();
        Call<ClubIntro>call=listsModel.getClubIntro(id);
        call.enqueue(new Callback<ClubIntro>() {
            @Override
            public void onResponse(Call<ClubIntro> call, Response<ClubIntro> response) {
                ClubIntro data=response.body();
                jianjie.setText(data.getIntroduction());
                telnum.setText("电话："+data.getClub_tel());
                place.setText("地点："+data.getCity_name());
                time.setText("时间："+data.getOpen_time());
                List<ClubIntro.ClubteacherEntity> teachers=data.getClubteacher();
                recyclerView.setAdapter(new TeacherAdpater(getActivity(),teachers));

            }

            @Override
            public void onFailure(Call<ClubIntro> call, Throwable t) {

            }
        });
    }
    private void initData() {
    }
}
